home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_8 / issue_06 / risc_os / Wimp / Icons < prev    next >
Encoding:
Text File  |  1988-12-06  |  14.3 KB  |  364 lines

  1. > Wimp.Icons
  2.  
  3. New Calls
  4. ---------
  5.  
  6.         system icons
  7.         scrollable icons
  8.         validation strings
  9.         sprite + text icons
  10.         button type 9
  11.         button type 11
  12.         inverting sprites
  13.  
  14.  
  15. System icons
  16. ------------
  17.  
  18. In Arthur 1.2, it was not possible to tell the difference between the pointer
  19. being over the work area of a window and being over one of the system icons
  20. (eg. title bar, scroll bar and so on).
  21.  
  22. When running new-style tasks (see Wimp.Desktop), the Wimp now returns
  23. different icon handles from Wimp_GetPointerInfo for each of the system icons,
  24. as follows:
  25.  
  26.         -1      work area (as before)
  27.         -2      back box
  28.         -3      quit box
  29.         -4      title bar
  30.         -5      toggle box
  31.         -6      scroll up button
  32.         -7      vertical scroll bar
  33.         -8      scroll down button
  34.         -9      size box
  35.         -10     scroll left button
  36.         -11     horizontal scroll bar
  37.         -12     scroll right button
  38.         -13     the line surrounding the window (not on an icon)
  39.  
  40. Most normal applications should not need to know about these icon handles,
  41. but it is occasionally useful for things like interactive help.
  42.  
  43. Some extra functions have been added to these icons since Arthur 1.2, so a
  44. full summary follows:
  45.  
  46.     back            SELECT sends the window to the back of the stack,
  47.                            with the same coordinates
  48.  
  49.     quit            SELECT closes the window
  50.                     ADJUST opens the parent directory (for Filer windows)
  51.  
  52.     title bar       SELECT brings the window to the front and allows the
  53.                            position to be altered
  54.                     ADJUST is similar but leaves the window at the same
  55.                            height in the stack
  56.  
  57.     toggle          SELECT if the window is not at its full size, opens
  58.                            the window at the front at its full size
  59.                            if already full size, the window is returned
  60.                            to its last non-full position in the stack
  61.                     ADJUST is similar but leaves the window at the same
  62.                            height in the stack when making full-size
  63.  
  64.     scroll up       SELECT scrolls the window up 32 OS units
  65.                     ADJUST scrolls the window down 32 OS units
  66.  
  67.     vertical scroll SELECT above the sausage scrolls up a page
  68.                     ADJUST above the sausage scrolls down a page
  69.  
  70.                     SELECT in the sausage drags up and down,
  71.                            opening the window at the front
  72.                     ADJUST in the sausage drags up and down,
  73.                            at the same height in the stack
  74.  
  75.                     SELECT below the sausage scrolls down a page
  76.                     ADJUST below the sausage scrolls up a page
  77.  
  78.     scroll down     SELECT scrolls the window down 32 OS units
  79.                     ADJUST scrolls the window up 32 OS units
  80.  
  81.     size            SELECT alters the window size, bringing it to the front
  82.                     ADJUST leaves the window at the same height in the stack
  83.  
  84.     scroll left         }
  85.     horizontal scroll   } these are analagous to the other scroll bar
  86.     scroll right        }
  87.  
  88.  
  89. Scrollable icons
  90. ----------------
  91.  
  92. User interface:
  93.  
  94.   SELECT  puts caret into icon
  95.  
  96.   Typing / moving the caret can cause the icon to scroll.
  97.  
  98.  
  99. Application:
  100.  
  101.   Create icon with 'writeable' bit set, as normal.
  102.   Length of buffer determines max string length,
  103.   Size of icon determines amount displayed.
  104.  
  105.  
  106. Validation Strings
  107. ------------------
  108.  
  109. If an icon is indirected, it can have a validation string associated with it
  110. as well as its own text string and maximum buffer size.  In the case of a
  111. writeable icon, this allows the application to tell the Wimp which characters
  112. it would like the user to be allowed to type into the icon.  Any characters
  113. disallowed by the validation string will be passed back to the application
  114. via Wimp_Poll (Key_Pressed), so they could still be meaningful.
  115.  
  116. The syntax of validation strings has been designed to be open-ended, to allow
  117. further enhancement in the future, but for the moment (Wimp 2.00) the
  118. following syntax prevails:
  119.  
  120. <validation string> ::= <command> { ; <command> }*
  121.           <command> ::= a <allow-spec> | d <display-spec>
  122.        <allow-spec> ::= { <char_spec> }* { ~ { <char-spec> }* }*
  123.         <char-spec> ::= <char> | <char> - <char>
  124.              <char> ::= \- | \; | \\ | \~ | <any character other than - ; \ ~>
  125.      <display-spec> ::= <char>
  126.  
  127. command letters are case-insensitive, and spaces are significant.
  128.  
  129. In simple terms, a validation string consists of a series of 'commands', each
  130. starting with a single letter, followed by various parameters and separated
  131. by ';'s.  The interpretation of the parameters depends on the initial letter
  132. of the command:
  133.  
  134. Following A
  135. -----------
  136.  
  137.   The (A)llow command tells the Wimp which characters are to be allowed in the
  138.   icon string.  When a key is typed by the user, and the input focus is inside
  139.   this icon, the Wimp checks the validation string to see if the character is
  140.   to be allowed in the string.  If it is, then the character will be inserted
  141.   in the icon string: otherwise, it will be returned to the application via
  142.   Wimp_Poll (Key_Pressed).
  143.  
  144.   Control keys such as the arrow keys and delete are automatically dealt with
  145.   by the Wimp - any other codes outside the range 32-255 will be returned to
  146.   the application whatever happens, and the other codes will be returned unless
  147.   the 'allow' string says that they can be included in the icon string.
  148.  
  149.   Basically each <char-spec> in the 'allow' string specifies a group of
  150.   characters which are to be included or excluded from the icon string.  The ~
  151.   character is used to toggle whether the Wimp is including or excluding the
  152.   specified characters, as follows:
  153.  
  154.     a0-9a-z~dpu
  155.  
  156.   In this case the Wimp would allow the digits 0-9 and the lower-case letters
  157.   a-z (except for 'd', 'p' and 'u').  Note that the initial state of whether
  158.   the letters are allowed or not is determined by whether the first letter
  159.   following the 'a' is a ~ or not:
  160.  
  161.     a~0-9
  162.  
  163.   Here all the normal characters except for the digits are allowed.
  164.  
  165.   The \ character is used as an escape character for ~ - ; \ to avoid syntax
  166.   problems, so for example to disallow ~ - ; \ one would use the following
  167.   validation string:
  168.  
  169.     a~\~\-\;\\
  170.  
  171. Following D
  172. -----------
  173.  
  174.   The (D)isplay command is used for password icons, where the icon is to be
  175.   entered into the computer in the normal way, but each character is to be
  176.   displayed differently, to avoid onlookers seeing the password:
  177.  
  178.     d*
  179.  
  180.   would cause the password to be displayed as a row of '*'s.  Note that if
  181.   the character is any of the four 'special' characters above, it must be
  182.   preceded by a '\', eg:
  183.  
  184.     d\-
  185.  
  186. Following F
  187. -----------
  188.  
  189.   The (F)ont colours command is used to specify the foreground and background
  190.   colours of an anti-aliased icon.  The problem is that the 'colour' field in
  191.   the icon flag word is re-used for the font handle, so the validation string
  192.   must be used to specify the font colour.  The 'F' is followed by 2 hex
  193.   digits, which specify the background and foreground (wimp) colours
  194.   respectively.  The Wimp then calls Wimp_SetFontColours (see Wimp.Colours) to
  195.   set up the font colours before printing the text.  The default colours are 0
  196.   and 7.
  197.  
  198. Following L
  199. -----------
  200.  
  201.   The (L)ine spacing command can be used to tell the Wimp that a text icon
  202.   may be formatted: that is, that if the text is too wide for the icon, it may
  203.   be split over several lines.  A decimal number should follow the 'L', which
  204.   indicates the vertical spacing between lines of text - if omitted, the
  205.   default is 40 (OS units).
  206.  
  207.   Currently this option should only be used with icons which are horizontally
  208.   and vertically centred, and do not contain an anti-aliased font.  The icon
  209.   should not be writeable, since the caret will not be positioned correctly
  210.   inside it.
  211.  
  212. Following S
  213. -----------
  214.  
  215.   The (S)prite name command can be used if the icon has been defined with
  216.   bits 0 and 1 both set (ie. it is a text and sprite icon).  In this case the
  217.   'S' command in the validation string can be used to specify the sprite
  218.   name, so that it can be different from the text!
  219.  
  220.     Sfoosprite
  221.  
  222.   Note that no space should follow the 'S', and the sprite name is at most 12
  223.   characters long.
  224.  
  225.   You can also put two sprite names after the 'S', separated by a comma, to
  226.   indicate that the first sprite should be used when the icon is not
  227.   highlighted, and the second one when it is.
  228.  
  229.   (See below for a full description of the Sprite+Text facility).
  230.  
  231.  
  232.  
  233. Sprite + Text icons
  234. -------------------
  235.  
  236. In the Arthur 1.20 Wimp, it was possible (but not very useful) to specify an
  237. icon as containing text and a sprite.  There were two reasons why this was
  238. not very useful:
  239.  
  240.      *  the text and the sprite appeared on top of one another
  241.      *  the sprite name was equal to the text
  242.  
  243. The new system gets round both those problems in the following way:
  244.  
  245. (1) The positioning of the text and the sprite depend on the various flags
  246.     combinations as follows:
  247.  
  248.         V = vertically centred    (bit 5 of icon flags)
  249.         H = horizontally centred  (bit 4)
  250.         R = right justified       (bit 9)
  251.         ~ = not set, otherwise set
  252.  
  253.     Vertical:
  254.                 V ==> both vertically centred             <== as before
  255.              HR~V ==> text at top, sprite at bottom
  256.                ~V ==> text at bottom, sprite at top
  257.     Horizontal:
  258.           ~V ~H~R ==> both at left                        <== as before
  259.           ~V ~H R ==> both at right                       <== as before
  260.           ~V  H   ==> both centred                        <== as before
  261.            V ~H~R ==> sprite at left, text +6 units to right (LJ)
  262.            V  H~R ==> both centred (text visible)         <== as before
  263.            V ~H R ==> text at left, sprite at right
  264.            V  H R ==> sprite at left, text at right (RJ)
  265.  
  266.     Thus the relative positions of the text and the sprite can be varied
  267.     simply by altering the dimensions of the overall icon.
  268.  
  269. (2) The sprite name can be made to be different from the text, as follows:
  270.  
  271.         a) the icon must be indirected
  272.         b) the text field, validation string and buffer length all have their
  273.            usual meanings for text icons
  274.         c) the sprite name is determined by the S field in the validation
  275.            string.  This can be used in conjunction with any other fields
  276.            (separated by ';') in the string.  Note that if you put two sprite
  277.            names after the 'S', separated by a comma, the Wimp will use
  278.            either the first or second sprite depending on whether the icon is
  279.            selected or not (and will not invert the sprite).
  280.         d) The sprite areaCBptr must be the same as the window's areaCBptr. 
  281.            In particular, this means that icons on the iconbar which contain
  282.            text as well as a sprite must refer to a sprite in the Wimp's
  283.            common sprite pool (see Wimp.Sprites and Wimp.IconBar).
  284.  
  285. The sprite+text icon suffers from the following drawbacks (if any of these
  286. are a problem, use two icons instead!):
  287.  
  288.         a) The text field can be writeable, and can even scroll, but
  289.            unfortunately the sprite will be redrawn every time a key is
  290.            pressed!
  291.         b) Because icon inversion causes the text to be redrawn with the
  292.            foreground and background colours swapped, even non-filled
  293.            sprite+text icons have the text filled (even when not inverted). 
  294.            This is so that Wimp_SetIconState can toggle the inversion state
  295.            without redrawing the window behind the icon.
  296.         c) Shading the icon <<<< is this true ???
  297.         d) If the text is anti-aliased, the icon must not have a filled
  298.            background, since the background of the anti-aliased text is
  299.            filled in after the sprite is drawn, thus obscuring it!
  300.         e) Mouse clicks will not be clipped to the sprite and text
  301.            individually (only the full box is considered).
  302.  
  303. The text+sprite facility is primarily intended as a means of getting a
  304. sprite/text pair onto the iconbar.  It is also useful for representing files
  305. (in any of the formats which the Finder supports) - note that 'small' files
  306. can be represented by setting bit 11 of the icon flags, which causes the
  307. sprite to be displayed at half size (see also Wimp.Colours for a description
  308. of the Wimp's default sprite scaling).
  309.  
  310.  
  311. Button type 9
  312. -------------
  313.  
  314. It has come to my attention that some people do not believe that the 'menu
  315. icon' button type (9) works correctly.  In fact it does, but is only
  316. meaningful if the ESG of the icon is non-zero, since otherwise the continuous
  317. selections that it makes when the pointer is over the icon cause it simply to
  318. flash.
  319.  
  320. This button type is extremely useful when constucting dialogue boxes that are
  321. intended to simulate menus, or for 'action' buttons.
  322.  
  323.  
  324. Button type 11
  325. --------------
  326.  
  327. Meaning:
  328.  
  329.         SELECT/ADJUST ==> select icon, and return &01/&04 to application
  330.         SELECT/ADJUST drag ==> return &10/&40 to application
  331.  
  332. Icon button type 11 is intended to facilitate the maintaining of an icon (or
  333. group of icons) in a dialogue box, so that the Wimp will automatically select
  334. the icon, and also notify the application when the icon is clicked, without
  335. doing any of the more esoteric actions, such as returning double-clicks.
  336.  
  337. ESG's, and the 'allow adjust' bit (bit 10) can be set in conjunction with
  338. this button type to produce the required effects.
  339.  
  340. Remember that there is also a new facility when specifying a text+sprite icon
  341. to have the Wimp alternate between two different sprites when selecting the
  342. icon (see above).
  343.  
  344.  
  345. Inverting sprites
  346. -----------------
  347.  
  348. On the Arthur 1.2 Wimp, inverting and shading of sprites was done by plotting
  349. the sprite's mask over it, using GCOL 3,<fg colour> and GCOL 2,2 modes
  350. respectively.
  351.  
  352. This meant that the desired effect was not produced in mode 15, where the
  353. meaning of the logical colours is completely different from that in mode 12.
  354.  
  355. On Arthur 2.0, true to the tradition of mode independence, the effect is
  356. achieved instead by manipulating the translation table used to plot the
  357. sprite, so that rather than inverting the colours that are plotted on the
  358. screen, the 'Wimp colours' of the sprite are inverted in the translation
  359. table.
  360.  
  361. The net effect of this is that sprites are inverted correctly in mode 15, and
  362. they also do not flicker when selected, as they used to do.
  363.  
  364.